#include<bits/stdc++.h>
using namespace std;
bool detect[3005];
struct node{
    int pos;
    int l;
    int r;
};
node car[3005];
void work()
{
    int n, m, l, vt;
    cin >> n >> m >> l >> vt;
    for(int i = 1; i <= n; i++)
    {
        int d, v, a;
        cin >> d >> v >> a;
        car[i].pos = d;
        if(a < 0)
        {
            if(v <=vt)
            {
                car[i].l = -1;
                car[i].r = -1;
            }
            if(v > vt)
            {
                a = -a;
                car[i].r = d;
                car[i].l = car[i].r + floor(float((v*v - vt*vt)/(2.0*a)));
            }
        }
        if(a > 0)
        {
            if(v > vt)
            {
                car[i].r = d;
                car[i].l = l;
            }
            if(v < vt)
            {
                car[i].r = v + ceil(float((vt*vt - v*v)/(2.0*a)));
                if(car[i].r > l)
                {
                    car[i].r = -1;
                    car[i].l = -1;
                }
            }
        }
    }
    for(int i = 1; i <= m; i ++)
    {
        int k;
        cin >> k;
        detect[k] = 1;
    }
    int sum1 = 0;
    for(int i = 1; i <= n; i ++)
    {
        for(int j = car[i].l; j <= car[i].r; j++)
        {
            if(detect[j])
            {
                sum1++;
                continue;
            }
        }
    }
    cout << sum1;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int t;
    cin >> t;
    for(int i = 1; i <= t; i++)
        work();
    return 0;
}
